package com.example.express.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class UserInfo {
    private int uid;
    private String pwd;
    private String name;
    private Integer uRull;
    private String telCode;
    private Integer status;
    private String dptId;
    private String receivePackageId;
    private String delivePackageId;
    private String transPackageId;
    private Collection<TransPackage> transPackages;

    @Id
    @Column(name = "UID")
    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    @Basic
    @Column(name = "PWD")
    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Basic
    @Column(name = "Name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "URull")
    public Integer getuRull() {
        return uRull;
    }

    public void setuRull(Integer uRull) {
        this.uRull = uRull;
    }

    @Basic
    @Column(name = "TelCode")
    public String getTelCode() {
        return telCode;
    }

    public void setTelCode(String telCode) {
        this.telCode = telCode;
    }

    @Basic
    @Column(name = "Status")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Basic
    @Column(name = "DptID")
    public String getDptId() {
        return dptId;
    }

    public void setDptId(String dptId) {
        this.dptId = dptId;
    }

    @Basic
    @Column(name = "ReceivePackageID")
    public String getReceivePackageId() {
        return receivePackageId;
    }

    public void setReceivePackageId(String receivePackageId) {
        this.receivePackageId = receivePackageId;
    }

    @Basic
    @Column(name = "DelivePackageID")
    public String getDelivePackageId() {
        return delivePackageId;
    }

    public void setDelivePackageId(String delivePackageId) {
        this.delivePackageId = delivePackageId;
    }

    @Basic
    @Column(name = "TransPackageID")
    public String getTransPackageId() {
        return transPackageId;
    }

    public void setTransPackageId(String transPackageId) {
        this.transPackageId = transPackageId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserInfo userInfo = (UserInfo) o;
        return uid == userInfo.uid &&
                Objects.equals(pwd, userInfo.pwd) &&
                Objects.equals(name, userInfo.name) &&
                Objects.equals(uRull, userInfo.uRull) &&
                Objects.equals(telCode, userInfo.telCode) &&
                Objects.equals(status, userInfo.status) &&
                Objects.equals(dptId, userInfo.dptId) &&
                Objects.equals(receivePackageId, userInfo.receivePackageId) &&
                Objects.equals(delivePackageId, userInfo.delivePackageId) &&
                Objects.equals(transPackageId, userInfo.transPackageId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid, pwd, name, uRull, telCode, status, dptId, receivePackageId, delivePackageId, transPackageId);
    }

    @JsonIgnore
    @OneToMany(mappedBy = "userInfo")
    public Collection<TransPackage> getTransPackages() {
        return transPackages;
    }

    public void setTransPackages(Collection<TransPackage> transPackages) {
        this.transPackages = transPackages;
    }
}
